package com.neuedu.his.framework.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebFilter(urlPatterns = "/*")
public class CrossFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletResponse resp = (HttpServletResponse) response;
//        resp.addHeader("Access-Control-Allow-Origin","*");
        resp.addHeader("Access-Control-Allow-Origin","http://127.0.0.1");
//        resp.addHeader("Access-Control-Allow-Origin","http://192.168.85.11:81");
        resp.addHeader("Access-Control-Allow-Credentials","true");
        chain.doFilter(request, response);
    }

    @Override
    public void destroy() {

    }
}